home *** CD-ROM | disk | FTP | other *** search
/ Programming a Multiplayer FPS in DirectX / Programming a Multiplayer FPS in DirectX (Companion CD).iso / DirectX / dxsdk_oct2004.exe / dxsdk.exe / Samples / C++ / Direct3D / OptimizedMesh / OptimizedMesh.fx < prev    next >
Encoding:
Text File  |  2004-09-27  |  1.8 KB  |  63 lines

  1. //--------------------------------------------------------------------------------------
  2. // File: OptimizedMesh.fx
  3. //
  4. // The effect file for the OptimizedMesh sample.  
  5. // 
  6. // Copyright (c) Microsoft Corporation. All rights reserved.
  7. //--------------------------------------------------------------------------------------
  8.  
  9.  
  10. //--------------------------------------------------------------------------------------
  11. // Global variables
  12. //--------------------------------------------------------------------------------------
  13. float4   g_vDiffuse;                // Material diffuse color
  14. float4x4 g_mWorld;                    // World matrix for object
  15. float4x4 g_mWorldViewProjection;    // World * View * Projection matrix
  16. texture  g_txScene;
  17.  
  18.  
  19. sampler g_samScene =
  20. sampler_state
  21. {
  22.     Texture = <g_txScene>;
  23.     MinFilter = Linear;
  24.     MagFilter = Linear;
  25.     MipFilter = None;
  26. };
  27.  
  28.  
  29. void VertScene( float4 Pos : POSITION,
  30.                 float3 Normal : NORMAL,
  31.                 float2 Tex : TEXCOORD0,
  32.                 out float4 oPos : POSITION,
  33.                 out float2 oTex : TEXCOORD0,
  34.                 out float4 Diffuse : COLOR0 )
  35. {
  36.     oPos = mul( Pos, g_mWorldViewProjection );
  37.  
  38.     float3 N = normalize( mul( Normal, (float3x3)g_mWorld ) );
  39.     Diffuse = saturate( dot( (float3)N, float3( 0.0f, 0.0f, -1.0f ) ) ) * g_vDiffuse;
  40.  
  41.     oTex = Tex;
  42. }
  43.  
  44.  
  45. float4 PixScene( float2 Tex : TEXCOORD0,
  46.                  float4 Diffuse : COLOR0 ) : COLOR0
  47. {
  48.     return tex2D( g_samScene, Tex ) * Diffuse;
  49. }
  50.  
  51.  
  52. //--------------------------------------------------------------------------------------
  53. // Techniques
  54. //--------------------------------------------------------------------------------------
  55. technique RenderScene
  56. {
  57.     pass P0
  58.     {
  59.         VertexShader = compile vs_1_1 VertScene();
  60.         PixelShader = compile ps_1_1 PixScene();
  61.     }
  62. }
  63.